<template>
	<view class="equipment">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				安装回收记录
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="left clearfix">
				<view class="mess fl">
					<view :class="[attrIndex==1?'active':'active1']" @click="attrInde1(1)">安装记录</view>
					<text class="dian" v-if="attrIndex == 1"></text>
				</view>
				<view class="mess mess1 fl" @click="attrInde1(2)">
					<view :class="[attrIndex==2?'active':'active2']">回收记录</view>
					<text class="dian" v-if="attrIndex == 2"></text>
				</view>
			</view>
		</view>
		<view class="nr" v-if="list.length != 0">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="liebiao clearfix">
					<view class="left fl">设备编码：</view>
					<view class="right fl">
						<view class="title">{{item.charger_number}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">设备名称：</view>
					<view class="right fl">
						<view class="title">{{item.charger_name}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">所在门店：</view>
					<view class="right fl">
						<view class="title">{{item.station_name}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">操作人：</view>
					<view class="right fl">
						<view class="title">{{item.nickname}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">时间：</view>
					<view class="right fl">
						<view class="title">{{item.create_time}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image :src="baseUrl + '/wximage/empty.png'"></image>
			<text>暂无相关数据</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				attrIndex: 1,
				formData: {
					id: '',
					page: 1,
					pageSize: 30,
					type: 1
				},
				list: []
			}
		},
		onLoad(options) {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			this.formData.id = options.id;
			//设备记录
			this.deviceRecode();
		},
		onReachBottom() {
			this.formData.page = this.formData.page + 1;
			this.deviceRecode();
		},
		methods: {
			attrInde1(item) {
				this.formData.page = 1;
				this.list = [];
				this.attrIndex = item;
				
				this.deviceRecode();
			},
			deviceRecode() {
				if (this.attrIndex == 1) {
					this.formData.type = 1
				} else {
					this.formData.type = 2
				}
				this.request({
					url: '/wxdevice/recodeahlist',
					data: this.formData,
					method: "GET"
				}).then(res => {
					if (res.data.code == 200) {
						if (res.data.data == null) {
							this.list = [];
						} else {
							this.list = this.list.concat(res.data.data.list);
						}
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			topage(url) {
				uni.redirectTo({
					url
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.equipment {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;

			.left {
				.mess {
					height: 48rpx;
					line-height: 48rpx;
					text-align: center;

					view {
						font-size: 24rpx;
						color: #333333;
					}

					.dian {
						width: 8rpx;
						height: 8rpx;
						background: #5C88FA;
						display: block;
						border-radius: 50%;
						margin: 0 auto;
					}

					.active {
						font-size: 32rpx;
						color: #333333;
						font-weight: 700;
						margin-left: 0;
					}
				}

				.mess1 {
					margin-left: 20rpx;
				}
			}

			.right {
				width: 170rpx;
				height: 36rpx;
				line-height: 36rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 24rpx;
				margin-top: 6rpx;

				.name {
					font-size: 24rpx;
					color: #333333;
				}
			}
		}

		.nr {
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: -200rpx;

			.list {
				width: 100%;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 40rpx 40rpx 10rpx;
				position: relative;
				margin-bottom: 20rpx;
				background: #fff;
				box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;

				.liebiao {
					margin-bottom: 30rpx;

					.left {
						font-size: 24rpx;
						color: #333333;
						width: 30%;
					}

					.right {

						.title {
							font-size: 24rpx;
							color: #333333;
						}

						.name {
							font-size: 24rpx;
							color: #5C88FA;
						}
					}
				}
			}

			.footer {
				width: 100%;
				margin-bottom: 20rpx;
				padding: 0 40rpx 40rpx;

				.left {
					width: 30%;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					font-size: 28rpx;
					border-radius: 16rpx;
					color: #333333;
					background: #F0F0F0;
					margin-left: 40rpx;
				}

				.right {
					width: 30%;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					font-size: 28rpx;
					border-radius: 16rpx;
					color: #FFFFFF;
					background: #3B91F8;
					margin-right: 40rpx;
				}
			}
		}
		
		.empty{
			width: 100%;
			margin: 200rpx auto 0;
			text-align: center;
			
			image{
				width: 390rpx;
				height: 340rpx;
			}
			
			text{
				display: block;
				margin-top: 60rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
	}
</style>